﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ue.Framework.Web.WebControls;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.SaleInfos;
using Ue.Qcdz.Domain;

namespace Ue.Qcdz.UI.Controls.SaleInfo
{
    public class SaleInfoShow : SkinnedControl
    {
        #region Overrides of SkinnedControl

        private string skinFileName = "~/Themes/zh-cn/Skins/SaleInfo/productInfo.ascx";
        private Image imgProductInfo;
        private Literal litProductInfo;
        protected override string GetSkinFileName()
        {
            return skinFileName;
        }

        protected override void InitializeSkin(Control skin)
        {
            //if (!string.IsNullOrEmpty(SiteContext.GetSiteContext().ProductID))
            //{
                imgProductInfo = skin.FindControl<Image>("imgProductInfo");
                litProductInfo = skin.FindControl<Literal>("litProductInfo");
                BidnSource();
            //}
            //else
            //{
            //    MessageWindow.RenderMessage("参数错误", "default.aspx");
            //}
        }
        private void BidnSource()
        {
            ISaleInfoRepository repository =
                Ue.Infrastructure.RepositoryFramework.RepositoryFactory.GetRepository<ISaleInfoRepository, Ue.Qcdz.Domain.SaleInfos.SaleInfo>();
            //string id = this.Page.Request["id"]; 
            string id = SiteContext.GetSiteContext().ProductID; //产品详细页 /company/Product.aspx
            Guid guidKey = new Guid(id);
            var saleInfo = repository.FindBy(guidKey);
            imgProductInfo.ImageUrl = saleInfo.PicUrl;
            litProductInfo.Text = saleInfo.Description;
        }

        #endregion
    }
}
